<template>
  <div class="home">
    <el-container>
      <el-header class="home_header">
        <div class="left">
          <img v-if="!collapse"
               @click="toIndex"
               class="marginlr"
               src="@/assets/logo.png"
               alt />
          <span v-else
                @click="toIndex">旋风</span>
          <i class="el-icon-s-fold setheight"
             @click="collapse=!collapse"></i>
          <span class="title"></span>
        </div>
        <div class="right">
          <img class="avatar"
               src="@/assets/logo.png"
               alt />
          <span class="name">欧尼酱，你来了</span>
          <el-button type="primary"
                     @click="exit">退出</el-button>
        </div>
      </el-header>
      <el-container>
        <el-aside class="home_aside"
                  width="auto">
          <el-menu :router="true"
                   :collapse="collapse"
                   :default-active="defaultActive"
                   class="menuTransition">
            <el-menu-item index="/home/chart">
              <i class="el-icon-pie-chart"></i>
              <span slot="title">数据概览</span>
            </el-menu-item>
            <el-menu-item index="/home/antv">
              <i class="el-icon-user"></i>
              <span slot="title">蚂蚁图表</span>
            </el-menu-item>
            <el-menu-item index="/home/question">
              <i class="el-icon-edit-outline"></i>
              <span slot="title">第一列表</span>
            </el-menu-item>
            <el-menu-item index="/home/business">
              <i class="el-icon-office-building"></i>
              <span slot="title">第一列表</span>
            </el-menu-item>
            <el-menu-item index="/home/subject">
              <i class="el-icon-notebook-2"></i>
              <span slot="title">第一列表</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main class="home_main">
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>

</template>

<script>
export default {
  data () {
    return {
      //  是否折叠菜单
      collapse: false,
      // 路由
      defaultActive: ''
    }
  },
  created () {
    this.defaultActive = this.$route.path
    // console.log(this.$route.path);
  },
  methods: {
    exit () {
      this.$message({
        message: '退出成功，个毛线',
        type: 'success'
      });
    },
    toIndex () {
      this.router.push('/home')
    }
  },
}
</script>

<style lang="less" scoped>
section.el-container.is-vertical {
  // background-color: #ccc;
}
.el-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #fff;
  box-shadow: 0px 2px 5px 0px rgba(63, 63, 63, 0.35);
  color: #333;
  text-align: center;
  line-height: 60px;
  height: 60px;
  z-index: 2;
  padding-left: 0;
  // margin-bottom: 4px;
  .left {
    display: flex;
    align-items: center;
    .setheight {
      font-size: 20px;
    }
    .marginlr {
      width: 150px;
      height: 60px;
      margin-left: 10px;
      margin-right: 10px;
    }
    span {
      width: 64px;
      font-size: 20px;
      font-weight: 700;
    }
    .title {
      font-size: 22px;
      font-family: Microsoft YaHei;
      font-weight: bold;
      color: rgba(73, 161, 255, 1);
    }
  }
  .right {
    display: flex;
    align-items: center;
    .avatar {
      width: 43px;
      height: 43px;
    }
    .name {
      margin-left: 10px;
      margin-right: 10px;
    }
  }
}

.el-aside {
  // width: 160px;
  // width: 0 !important;
  height: calc(100vh - 80px);
  background: rgba(255, 255, 255, 1);
  // box-shadow: 0px 2px 5px 0px rgba(63, 63, 63, 0.35);
  z-index: 2;
}
.menuTransition:not(.el-menu--collapse) {
  // 初始宽度
  width: 160px;
}

.el-main {
  height: calc(100vh - 80px);
  overflow: auto;
  background-color: #e8e9ec;
}
</style>